package revice;

/*
 * Author: JacksonCoder
 * FileName: basice
 * Version: 1.0.0
 * Date: 2025/8/3
 */

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class basic {

    public static void main(String[] args) {
        System.out.println("hello world");

        Runnable r1 = new Runnable() {
            @Override
            public void run() {
                System.out.println("this is " + Thread.currentThread().getName() + " running!");
            }
        };

        // lambda 写法
        Runnable r2 = () -> System.out.println("this is " + Thread.currentThread().getName() + " running!");


        new Thread(r1).start();
        new Thread(r2).start();

        // 作为参数传递
        new Thread(() -> System.out.println("this is " + Thread.currentThread().getName() + " running!")).start();

        streamUse();
    }

    public static void streamUse() {
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        Stream<Integer> intList = list.stream();
        for (int i : intList.collect(Collectors.toList())) {
            System.out.println(i);
        }

        IntStream s2 = Arrays.stream(new int[]{1, 2, 3, 4, 5, 6, 7});
        s2.forEach(System.out::println);

        Stream<String> s3 = Stream.of("a", "b", "c", "d", "e");
        s3.collect(Collectors.toList()).forEach(System.out::println);

    }


}
